<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\SoftDeletes;
/**
 * @property int $id 主键
 * @property string $name 设备名称
 * @property string $model 产品型号
 * @property string $sn SN编码
 * @property string $sim SIM编码
 * @property string $imei IMEI编码
 * @property int $is_use 是否使用或绑定车辆；0否；1是
 * @property int $status 状态
 * @property string $remark 备注
 * @property int $created_user 创建人
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 * @property string $deleted_at 软删除字段
 */
class GpsDevice extends BaseModel
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'gps_devices';

    protected $hidden = ['deleted_at'];
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'name', 'model', 'sn', 'sim', 'imei', 'is_use', 'last_login_time', 'term_type', 'ver', 'device_pwd', 'gps', 'gsm', 'battery_power', 'device_status', 'status', 'remark', 'created_user', 'created_at', 'updated_at', 'deleted_at'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'is_use' => 'integer', 'gps' => 'integer', 'gsm' => 'integer', 'battery_power' => 'integer', 'device_status' => 'integer', 'status' => 'integer', 'created_user' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
    /**
     * [vehicle 关联车辆]
     * @return [type] [description]
     */
    public function vehicle()
    {
        return $this->hasOne(Vehicle::class, 'device_id', 'id');
    }
    /**
     * [createuser 创建者]
     * @return [type] [description]
     */
    public function createuser()
    {
        return $this->hasOne(User::class, 'id', 'created_user');
    }
}